/**
 * 系统管理--我的租车信息
 */
var activity = {
    id: "activityTable", //表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1,
    condition: {
    }
};

/**
 * 初始化表格的列
 */
activity.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {
            title: '序号', field: 'number', width: 1, align: 'center', valign: 'middle', formatter: function (value, row, index) {
                return index + 1;
            }
        },
        {title: 'activityId', field: 'activityId', visible: false, align: 'center', valign: 'middle'},
        {title: '活动名称', field: 'activityName', align: 'center', valign: 'middle', sortable: true},
        {title: '活动内容', field: 'activityNote', align: 'center', valign: 'middle', sortable: true},
        {title: '折扣力度', field: 'activityDiscount', align: 'center', valign: 'middle', sortable: true, formatter: function (value, row, index) {
                return  '租车' + row.activityDiscount + '折'
            }},
        {title: '开始时间', field: 'startTime', align: 'center', valign: 'middle', sortable: true},
        {title: '结束时间', field: 'endTime', align: 'center', valign: 'middle', sortable: true},
        {title: '是否过期', field: 'isTimeout', align: 'center', valign: 'middle', sortable: true, formatter: function(value, row, index){
                if (row.isTimeout === 1) return '<button type="button" class="btn btn-xs btn-warning" readonly >已过期</button>';
                return '<button type="button" class="btn btn-xs btn-success" readonly>未过期</button>'
            }
        }
    ];
};

$(function () {
    activity.app = new Vue({
        el: '#activityManagerPage',
        data: activity.condition
    });
    var defaultColunms = activity.initColumn();
    var table = new BSTable("activityTable", "/activity/activityList", defaultColunms);
    table.setPaginationType("client");
    activity.table = table.init();
    laydate.render({
        elem: '#timeLimit',
        range: true,
        theme: '#009efb',
        max: Feng.currentDate()
    });
});